#ifndef DEVICE_SYNTAXHIGHLIGHT_H
#define DEVICE_SYNTAXHIGHLIGHT_H

#include <QSyntaxHighlighter>
#include <QTextDocument>
#include <QVector>
#include <QTextCharFormat>
#include <QRegularExpression>

class DeviceSyntaxHighlight : public QSyntaxHighlighter
{
    Q_OBJECT
public:
    DeviceSyntaxHighlight(QTextDocument* parent);

protected:
    virtual void highlightBlock(const QString& text) override;

private:
    struct _HightRule {
        QRegularExpression pattern;  //匹配格式
        QTextCharFormat format;      //样式
    };

    void initRules();
    QVector<_HightRule> _rules;
};

#endif // DEVICE_SYNTAXHIGHLIGHT_H
